package com.chinasoft04.mall.utils;

import com.chinasoft04.mall.dto.Picture;
import org.im4java.core.ConvertCmd;
import org.im4java.core.GMOperation;
import org.im4java.core.IM4JavaException;

import java.io.IOException;

public class Magick {

    public Picture reSize(Picture picture,String realPath) throws IOException, InterruptedException, IM4JavaException {


//        System.out.println("真实地址："+realPath);
        GMOperation op = new GMOperation();
        ConvertCmd cmd = new ConvertCmd(true);


        op.addImage(realPath+picture.getPic());
        op.resize(200,200);
        op.addImage(realPath+picture.getPics_sma());
        cmd.run(op);

        op.addImage(realPath+picture.getPic());
        op.resize(400,400);
        op.addImage(realPath+picture.getPics_mid());
        cmd.run(op);

        op.addImage(realPath+picture.getPic());
        op.resize(800,800);
        op.addImage(realPath+picture.getPics_big());
        cmd.run(op);



        return picture;
    }
}
